package com.shamoa.springbootredis.demos.messageListener;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author zy
 * @version 1.0
 * @date 2024/3/24 14:54
 * @description redis消息发送者
 **/
@Component
public class RedisMessagePublisher {

    @Resource
    private RedisTemplate redisTemplate;

    @Scheduled(cron = "0/30 * * * * ? ")
    public void pubMsg() {
        System.out.println("发送消息中...");
        redisTemplate.convertAndSend("redis-channel", "hello reids");
    }


}
